package com.infomanage.enums;


import java.util.HashMap;
import java.util.Map;

/**
 * 学历类型枚举
 * 
 */
public enum DegreeType {
	XX(1, "小学"),
	CZ(2, "初中"),
	GZ(3, "高中"),
	DZ(4, "大专"),
	BK(5, "本科"),
	SS(6, "硕士"),
	BS(7, "博士");
	
	private int value;
	private String title;

	DegreeType(int value, String title) {
		this.value = value;
		this.title = title;
	}

    /**
     * 获取枚举值
     * @return 返回枚举值
     */
	public int value() {
		return this.value;
	}

    /**
     * 获取枚举标题
     * @return 返回枚举的标题
     */
	public String title() {
		return this.title;
	}

	private static Map<String, DegreeType> titlefinder;
	static {
		titlefinder = new HashMap<String, DegreeType>();
		for (DegreeType item : DegreeType.values())
			titlefinder.put(item.title(), item);

	}

	private static Map<Integer, DegreeType> valuefinder;
	static {
		valuefinder = new HashMap<Integer, DegreeType>();
		for (DegreeType item : DegreeType.values())
			valuefinder.put(new Integer(item.value()), item);

	}

	/**
	 * 按照枚举值查找枚举
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static DegreeType valueOf(int type) {
		return valuefinder.get(new Integer(type));
	}
	
	/**
	 * 按照枚举标题查找枚举值
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static DegreeType titleOf(String title) {
		return titlefinder.get(title);
	}
	
	public static DegreeType[] getMembers() {
		return new DegreeType[] {XX, CZ, GZ, DZ, BK, SS, BS};
	}
}
